package com.zhuang.chapter09.work03;

import java.util.Arrays;
import java.util.Scanner;

public class ErrorsTriangle {
	public static void triangle(int a, int b, int c) throws Exception {
		if (a + b > c && c - a < b) {
			System.out.println("能构成三角形");
			System.out.println("a=" + a + "," + "b=" + b + "," + "c=" + c);
		} else {
			throw new IllegalArgumentException("a=" + a + "," + "b=" + b + "," + "c=" + c + "不能构成三角形");
		}
	}

	public static void main(String[] args) {
		int a[] = new int[3];
		System.out.println("输入三个整数并用,分隔");
		Scanner sc = new Scanner(System.in);
		String[] strings = sc.nextLine().split(",");

		for (int i = 0; i < strings.length; i++) {
			a[i] = Integer.parseInt(strings[i]);
		}
		Arrays.sort(a);
		try {
			triangle(a[0], a[1], a[2]);
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
